package com.njust.view;

import org.springframework.web.servlet.View;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

public class MyView implements View {

    /**
     * 返回数据的内容类型
     * @return
     */
    @Override
    public String getContentType() {
        return "text/html";
    }


    @Override
    public void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
        System.out.println("之前保存的数据：" + model);
        response.setContentType("text/html");
        List<String> vn = (List<String>) model.get("video");
        for (String string : vn) {
            response.getWriter().write("<a>下载"+string+".avi</a><br/>");
        }
        response.getWriter().write(""
                + "<script>"
                + "var aEle = document.getElementsByTagName('a');"
                + "aEle.onclick=function(){"
                + "alert('想下载吗？交学费')"
                + "}"
                + "</script>");
    }
}
